// com/interview/case02/Main.java
package com.interview.case02;

import java.math.BigDecimal;
import java.math.RoundingMode;

public class Main {
    public static void main(String[] args) {
        // 创建购物车
        ShoppingCart cartB = new ShoppingCart();

        // 顾客B购买的水果斤数
        int applesB = 2;        // 2斤苹果
        int strawberriesB = 4;  // 4斤草莓
        int mangoesB = 3;       // 3斤芒果

        // 将水果添加到购物车
        Fruit apple = new Apple();
        Fruit strawberry = new Strawberry();
        Fruit mango = new Mango();
        cartB.addFruit(apple, applesB);
        cartB.addFruit(strawberry, strawberriesB);
        cartB.addFruit(mango, mangoesB);

        // 计算总价
        BigDecimal totalB = cartB.calculateTotalPrice();

        // 预期总价：2 * 8.00 + 4 * 13.00 + 3 * 20.00 = 16.00 + 52.00 + 60.00 = 128.00元
        BigDecimal expectedB = new BigDecimal("2").multiply(new BigDecimal("8.00"))
                                .add(new BigDecimal("4").multiply(new BigDecimal("13.00")))
                                .add(new BigDecimal("3").multiply(new BigDecimal("20.00")));

        // 设置小数点精度
        totalB = totalB.setScale(2, RoundingMode.HALF_UP);
        expectedB = expectedB.setScale(2, RoundingMode.HALF_UP);

        // 输出结果
        System.out.println("顾客B购买的总价: " + totalB + " 元");

        // 验证计算结果
        if (totalB.compareTo(expectedB) == 0) {
            System.out.println("测试通过！");
        } else {
            System.out.println("测试失败！预期: " + expectedB + " 元, 实际: " + totalB + " 元");
        }
    }
}
